package cn.schoolwow.util.module.crypto.common.flow;

import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;

public class ByteToStringFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        byte[] bytes = flowContext.checkData("bytes", byte[].class);
        StringBuilder sb = new StringBuilder();
        for (byte b : bytes) {
            sb.append(String.format("%02x", b));
        }
        flowContext.putReturnData("string", sb.toString());
    }

    @Override
    public String name() {
        return "字节数组转字符串";
    }
}
